package com.chexiehui.jc.ui.activity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.aries.ui.view.radius.RadiusTextView;
import com.blankj.utilcode.util.StringUtils;
import com.chexiehui.jc.R;
import com.chexiehui.jc.base.BaseActivity;
import com.chexiehui.jc.utils.BundleBuilder;

import butterknife.BindView;
import butterknife.OnClick;

public class SubmitSuccessTipActivity extends BaseActivity {
    @BindView(R.id.iv_tip_icon)
    ImageView ivTipIcon;
    @BindView(R.id.tv_tip_text)
    TextView tvTipText;
    @BindView(R.id.rtv_next)
    RadiusTextView rtvNext;

    private String tipText;
    private String btnText;
    private int tipIcon;

    @Override
    protected void setTitleBar() {
        titleBar.setTitleMainText("操作提示");
    }

    @Override
    protected void beforeSetView() {
        Bundle bundle = getIntent().getExtras();
        if(bundle != null){
            tipText = bundle.getString("tipText");
            tipIcon = bundle.getInt("tipIcon");
            btnText = bundle.getString("btnText");
        }
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_submit_success_tip;
    }

    @Override
    protected void initView(Bundle var1) {
        ivTipIcon.setImageResource(tipIcon <= 0 ?  R.mipmap.ic_change_finish : tipIcon);
        tvTipText.setText(StringUtils.isTrimEmpty(tipText) ? "操作成功" : tipText);
        rtvNext.setText(StringUtils.isTrimEmpty(btnText) ? "我知道了" : btnText);
    }

    public static void start(BaseActivity activity, String tipText,String btnText, int tipIcon){
        activity.startActivity(activity, SubmitSuccessTipActivity.class,
                new BundleBuilder()
                        .putString("tipText", tipText)
                        .putString("btnText", btnText)
                        .putInt("tipIcon", tipIcon).create(), R.anim.anim_fade_in, R.anim.anim_fade_out);
    }

    @OnClick(R.id.rtv_next)
    public void onViewClicked() {
        onBackPressed();
    }

    @Override
    public void onBackPressed() {
        finish();
        overridePendingTransition(R.anim.anim_fade_in, R.anim.anim_fade_out);
    }
}
